package sui.utils.format;

import java.text.NumberFormat;

public class TestNumberFormat
{
    public static void main(String[] args) {

            NumberFormat nFormat=NumberFormat.getNumberInstance();
            nFormat.setMinimumIntegerDigits(3);//设置整数部分至少为3位
            nFormat.setMaximumFractionDigits(5);//设置小数点后面尾数为5
        System.out.println("Format Out 3.2128345="+nFormat.format(3.2128345));

            NumberFormat cFormat=NumberFormat.getCurrencyInstance();
            cFormat.setMaximumFractionDigits(3);
        System.out.println("Format Out 321283.47656="+cFormat.format(321283.47656));

            NumberFormat pFormat=NumberFormat.getPercentInstance();
            pFormat.setMaximumFractionDigits(4);
        System.out.println("Format Out 3.2128345="+pFormat.format(3.2128345));

        System.out.println("Format Out null="+nFormat.format(null));//参数是null,出现异常
        //Throws  IllegalArgumentException
    }
}